#include <iostream>
#include <string>
#include <cstdio>
#include <string.h>
#include <errno.h>
#include <cstdlib>
#include <unistd.h>


int main()
{
	pid_t id = fork();
	if(id < 0)
	{
		printf("errno : %d, errstring: %s\n",errno,strerror(errno));
		return errno;
	}
	else if(id == 0)
	{
		int cnt = 10;
		while(cnt)
		{
			printf("子进程运行中, pid: %d\n",getpid());
			cnt--;
			sleep(1);
		}
		exit(0);
	}
	else
	{
		while(true)
		{
			printf("我是父进程: pid: %d\n",getpid());
			sleep(1);
		}
	}
	return 0;
}

